namespace IMPlant.Core.Web.Control.GridViewFunction
{
    using IMPlant.Core.Web.Control;
    using IMPlant.Core.Web.Control.Helper;
    using System;

    public class MergeCellsFunction : ExtendFunction
    {
        public MergeCellsFunction()
        {
        }

        public MergeCellsFunction(GridView grid) : base(grid)
        {
        }

        private void _grid_RowsDataBound(object sender, EventArgs e)
        {
            string[] strArray = Common.ReplaceCommaChars(base._grid.MergeCells).Split(new char[] { ',' });
            int length = strArray.Length;
            int[] columnIndices = new int[length];
            for (int i = 0; i < length; i++)
            {
                int num3;
                if (!int.TryParse(strArray[i], out num3))
                {
                    num3 = -1;
                }
                columnIndices[i] = num3;
            }
            GridViewHelper.MergeCells(base._grid, columnIndices);
        }

        protected override void Execute()
        {
            base._grid.RowsDataBound += new GridView.RowsDataBoundHandler(this._grid_RowsDataBound);
        }
    }
}

